package com.yh.rent.entity;

import java.util.Set;
import java.util.TreeSet;

import javax.persistence.*;

/**
 * 
 * ��������rent��Ŀ ��Ӧ�û���
 *  
 * @author: Administrator  
 * @date�� 2017-10-31 3:52:28 PM  
 * @version 1.0
 */
@Entity
@Table(name = "users")
public class User {
	private Integer id ;
	private String name ;//姓名
	private String password ;
	private String telphone ;
	private String userName ;//用户名
	private String isAdmin ;
	private Set<House> houses = new TreeSet<>() ;
	public User() {
		super();
	}
	public User(Integer id, String name, String password, String telphone, String userName, String isAdmin) {
		super();
		this.id = id;
		this.name = name;
		this.password = password;
		this.telphone = telphone;
		this.userName = userName;
		this.isAdmin = isAdmin;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE , generator = "mygenerator")
	@SequenceGenerator(name = "mygenerator", sequenceName = "user_seq", initialValue = 3 , allocationSize = 1)
	@Column(name="user_id")
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	@Column(name = "name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "password")
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	@Column(name = "telphone")
	public String getTelphone() {
		return telphone;
	}
	public void setTelphone(String telphone) {
		this.telphone = telphone;
	}
	
	@Column(name = "userName")
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@Column(name = "isAdmin")
	public String getIsAdmin() {
		return isAdmin;
	}
	public void setIsAdmin(String isAdmin) {
		this.isAdmin = isAdmin;
	}
	@OneToMany(cascade=CascadeType.ALL, mappedBy="user")
	public Set<House> getHouses() {
		return houses;
	}
	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}
	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", password=" + password + ", telphone=" + telphone + ", userName="
				+ userName + ", isAdmin=" + isAdmin + "]";
	}
	
}
